﻿$evidence = [System.Reflection.Assembly]::GetExecutingAssembly().Evidence


[Reflection.Assembly]::LoadFile("D:\Tools\MESF\Main\Powershell\Modules\SvnManagement\SharpSvn.dll")

$svnUrl = "https://mesf.svn.codeplex.com/svn/Main/ApplicationServices"


$svnClient = new-object SharpSvn.SvnClient 

$svnWorkingCopy = New-Object SharpSvn.SvnWorkingCopyClient


$svnClient.Authentication.add_SslServerTrustHandlers({
        $_.AcceptedFailures = $_.Failures
        $_.Save = $True
    })


$svnLocalPath = "D:\temp\Test"

$repoUri = new-object SharpSvn.SvnUriTarget($svnUrl) 

$svnClient.Authentication.DefaultCredentials = New-Object System.Net.NetworkCredential($svnUsername,$svnPassword)

$svnClient.ch .CheckOut($repoUri, $svnLocalPath) 


$svnClient.GetUriFromWorkingCopy($svnLocalPath)

$result=$null
$svnClient.GetInfo($svnLocalPath, [ref] $result)


$svnarg = New-Object  SharpSvn.SvnStatusArgs -Property @{
                                                Depth = [SharpSvn.SvnDepth]::Infinity
                                                RetrieveRemoteStatus = $true
                                                RetrieveAllEntries = $true
                                                }


$result=$null
$svnClient.GetStatus($svnLocalPath, $svnarg, [ref] $result)
$result


$svnCleanupArg = New-Object  SharpSvn.SvnCleanupArgs -Property @{
#CommandType=[SharpSvn.SvnCommandType]::CleanUp
#IsLastInvocationCanceled= $false
#Warnings=$null 
#LastException=$null          
ThrowOnCancel=$True
ThrowOnWarning=$False
ThrowOnError=$True                                                
}

$svnClient.CleanUp($svnLocalPath,$svnCleanupArg)


$svnRevertArgs = New-Object SharpSvn.SvnRevertArgs -Property @{
#CommandType=[SharpSvn.SvnCommandType]::Revert
#IsLastInvocationCanceled= $false
#Warnings=$null 
#LastException=$null          
ThrowOnCancel=$True
ThrowOnWarning=$False
ThrowOnError=$True                                                
Depth=[SharpSvn.SvnDepth]::Infinity
}


$svnClient.Revert($svnLocalPath, $svnRevertArgs)



$svnCommitArgs = New-Object SharpSvn.SvnCommitArgs -Property @{
RunTortoiseHooks=$False
IncludeDirectoryExternals=$False
IncludeFileExternals=$False
KeepChangeLists=$False
#ChangeLists
KeepLocks=$False
#CommandType=[SharpSvn.SvnCommandType]::Commit
#LogProperties
LogMessage="Hello"
#IsLastInvocationCanceled
#Warnings
#LastException             
ThrowOnCancel=$True
ThrowOnWarning=$False
ThrowOnError=$True                                                
Depth=[SharpSvn.SvnDepth]::Infinity
}

$svnCommitResults=$null
$svnClient.Commit($svnLocalPath, $svnCommitArgs, [ref] $svnCommitResults)



$svnUpdateArgs = New-Object SharpSvn.SvnUpdateArgs -Property @{
UpdateParents=$False
AddsAsModifications=$False
AllowObstructions=$False
#CommandType=[SharpSvn.SvnCommandType]::Update
#Revision                 
IgnoreExternals=$False
KeepDepth=$False
#IsLastInvocationCanceled
#Warnings
#LastException             
ThrowOnCancel=$True
ThrowOnWarning=$False
ThrowOnError=$True                                                
Depth=[SharpSvn.SvnDepth]::Infinity
}

$svnUpdateResult=$null
$svnClient.Update($svnLocalPath, $svnUpdateArgs, [ref] $svnUpdateResult)


$svnCreateDirectoryArgs = New-Object SharpSvn.SvnCreateDirectoryArgs -Property @{
MakeParents=$False
CreateParents=$False
#CommandType=[SharpSvn.SvnCommandType]::CreateDirectory
LogMessage="hello2"
#IsLastInvocationCanceled=$false
#Warnings
#LastException
ThrowOnCancel=$True
ThrowOnWarning=$False
ThrowOnError=$True                                                
}


$targetUrl = [System.IO.Path]::Combine($svnUrl,"titi").Replace("\","/")
$targetUrl

$svnCreateDirectoryResult = $null
$svnClient.RemoteCreateDirectory($targetUrl, $svnCreateDirectoryArgs, [ref] $svnCreateDirectoryResult)



